// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id              String    @id @default(uuid()) @map("_id")
  name            String?
  username        String?   @unique
  bio             String?
  email           String?   @unique
  emailVerified   DateTime?
  image           String?
  coverImage      String?
  profileImage    String?
  hashedPassword  String?
  createdAt       DateTime  @default(now())
  updatedAt       DateTime  @updatedAt
  followingIds    String[]
  hasNotification Boolean?

  posts         Post[]
  comments      Comment[]
  notifications Notification[]
}

model Post {
  id        String   @id @default(uuid()) @map("_id")
  body      String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  userId    String
  likedIds  String[]

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  comments Comment[]
}

model Comment {
  id        String   @id @default(uuid()) @map("_id")
  body      String
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  userId    String
  postId    String

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
  post Post @relation(fields: [postId], references: [id], onDelete: Cascade)
}

model Notification {
  id        String   @id @default(uuid()) @map("_id")
  body      String
  userId    String
  createdAt DateTime @default(now())

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
